package com.store.app.wxapi;

import android.app.Activity;
import android.util.Log;

import com.store.app.utils.SettingData;
import com.tencent.mm.sdk.modelpay.PayReq;
import com.tencent.mm.sdk.openapi.IWXAPI;
import com.tencent.mm.sdk.openapi.WXAPIFactory;

/**
 * Created by Administrator on 2016/3/30.
 */
public class WetchatPay {
    private final IWXAPI msgApi;
    private PayReq req;//
    public WetchatPay(Activity activity,WXOrderbean wxOrderbean){
        req = new PayReq();
        req.appId = wxOrderbean.getAppid();
        req.nonceStr = wxOrderbean.getNoncestr();
        req.packageValue = wxOrderbean.getPackageX();
        req.partnerId = wxOrderbean.getPartnerid();
        req.prepayId = wxOrderbean.getPrepayid();
        req.timeStamp = wxOrderbean.getTimestamp();
        req.sign = wxOrderbean.getSign();
        msgApi = WXAPIFactory.createWXAPI(activity, SettingData.APP_ID, true);
        msgApi.registerApp(wxOrderbean.getAppid());

    }

    public void pay(){
        Log.v("zyl","调用pay");
        msgApi.sendReq(req);//调用微信支付SDK
    }

    @Override
    public String toString() {
        return  req.appId+" "+req.nonceStr+" "+req.packageValue +" "+req.partnerId+" "+ req.prepayId+" "+ req.timeStamp+" "+req.sign+" ";
    }
}
